//
//  SZLPublicCirController.m
//  Shengzhuli
//
//  Created by 卡忙科技 on 16/12/15.
//  Copyright © 2016年 kamangkeji. All rights reserved.
//

#import "SZLPublicCirController.h"
#import "AddressField.h"
#import "WineFriendsNetwork.h"
#import "MBProgressHUD+MJ.h"
#import "SZLAccountHelper.h"

@interface SZLPublicCirController ()

@property (weak, nonatomic) IBOutlet AddressField *contentView;

@end

@implementation SZLPublicCirController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"发布新内容";
    self.contentView.placeHolder = @"请输入要发布的内容";
}
- (IBAction)publicClick
{
    if (self.contentView.text.length<1) {
        [MBProgressHUD showError:@"请输入要发布的内容" toView:self.view];
        return;
    }
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"token"] = [SZLAccountHelper shareInstance].token;
    params[@"content"] = self.contentView.text;
    __WEAK
    [self showWaiter];
    [WineFriendsNetwork publicWineFriendsCirWithParame:params response:^(BOOL success, NSString *msg) {
        [self hideWaiter];
        if (success) {
            [MBProgressHUD showSuccess:@"发布成功" toView:self.view];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                self.publicSuccess();
                [weakSelf.navigationController popViewControllerAnimated:YES];
            });
        }else{
            [MBProgressHUD showError:msg toView:self.view];
        }
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
